﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RRHH.Entities;
using System.Data.SqlClient;
using System.Data;


namespace RRHH.DataAccess
{
    public class DAOCatalogo
    {
        public List<BECatalogo> ListarCatalogo(BECatalogo _OBECatalogo)
        {
            string sql = "SP_LISTAR_CATALOGO";

            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.Parameters.Add("@IDDOMINIO", SqlDbType.Int).Value = _OBECatalogo.idDominio;

            sqlCommand.CommandText = sql;
            sqlCommand.CommandType = CommandType.StoredProcedure;

            using (DataAccess adoDataService = new DataAccess())
            {
                List<BECatalogo> _BLCatalogo = new List<BECatalogo>();
                IDataReader dr = adoDataService.ExecuteReader(sqlCommand);

                while (dr.Read())
                {
                    BECatalogo _BECatalogo = new BECatalogo();
                    _BECatalogo.idAuto = Convert.ToInt32(dr["IDAUTO"]);
                    _BECatalogo.nombre = Convert.ToString(dr["NOMBRE"]);
                    _BECatalogo.estado = Convert.ToString(dr["ESTADO"]);
                    _BLCatalogo.Add(_BECatalogo);
                }
                dr.Close();

                adoDataService.Dispose();

                return _BLCatalogo;
            }
        }
    }
}
